<?
class Combate {
	
	protected $data = array();
	protected $atacante;
	protected $defensor;
	protected $rounds;
	protected $estado;
	
	function __construct ($atacante, $defensor) {
		$this->data['id']	= rand(1,999999);
		$this->combatentes = new ListaDeElementos;
		
		$this->data['ata_initiative'] = $atacante->getValue('initiative') + rand(1, 20);
		$this->data['def_initiative'] = $defensor->getValue('initiative') + rand(1, 20);

		$this->data['atacante'] = $atacante->getValue('nome');
		$this->data['defensor'] = $defensor->getValue('nome');
		
		$atacante->setValue('combateId', $this->data['id']);
		$defensor->setValue('combateId', $this->data['id']);

		$this->estado = 1;
	}
	
	public function existeActor($actor) {
		return $this->combatentes->existe($actor->getValue('nome'));
	}
	
	public function avancarRound() {
		$this->rounds++;
	}
	
	public function getValue($key) {
		return $this->data[$key];
	}
	
	public function toArray() {
		return $this->data;
	}
}
?>